﻿/**************************
*项目启动入口
*qykings
*2010-09-01
*又是开学季啊，，，，，
*用于win下的测试用
*
**/

/***
*先不做跨平台
*有空在搞
**/

#include <stdio.h>
#include <iostream>
#include "./net/SGameSocket.h"


#include "./file/fileOperate.h"

#include <fstream>
#include <cassert>
#include "./common/json/cJSON.h"

#include "mgr/DataMgr.h"

#include "ServerConfig.h"

#include "base.h"

#include "./eatBall/MsgHandle.h"

#include "./utils/IpUtils.h"


#pragma comment(lib,"ws2_32.lib")

#pragma comment(lib, "pthreadVC2.lib")  //必须加上这句



int decodeMsg(CByteArrays cby, int id)
{
	printf("decodeMsg");
	MsgHandle::GetInstance()->decodeMsg(cby, id);
	return 0;
}





int main()
{
    printf( "kserver is start" );


	ServerConfig serverconfig;
	serverconfig.loadJson("../src/conf/serverConf");

   #ifdef WIN32
	WSADATA w;

	WSAStartup(0x0101, &w);//这一行必须在使用任何SOCKET函数前写！
#endif

	IpUtils iputils;
	const char *IP = iputils.getLocalIp();
	std::cout << "ip:" << IP << std::endl;
	printf("port:%d\n", DataMgr::GetInstance()->port);

	SGameSocket::GetInstance()->setCallFun(decodeMsg);
	SGameSocket::GetInstance()->creat(IP, DataMgr::GetInstance()->port);



	return 0;
}
